<?php
$im = imagecreate(55, 30);
$black = ImageColorAllocate($im, 0, 0, 0);
$white = ImageColorAllocate($im, 255, 255, 255);

srand(microtime()*1000000);

$str = 0;
while($str <= 20000) {
    $str = rand()%99999 + 1;
}
$str = strval($str);
$code = md5(crypt($str, "Vd"));
//setcookie('auth_num', $code, 0, '/', 'http://simpleit.us');
setcookie('auth_num', $code, (time() - 24*3600));

imagefilledrectangle($im, 0, 0, 55, 30, $white);
//imagestring($im, 5, 6, 6, $HTTP_GET_VARS['authnum'], $black);
imagestring($im, 5, 6, 6, $str, $black);

srand(microtime()*1000000);

for($i = 0; $i < 200; $i++) {
    $randcolor = ImageColorallocate($im, rand(0, 255), rand(0, 255), rand(0, 255));
    imagesetpixel($im, rand()%50 + 2, rand()%26 + 2 , $randcolor);
}

//header("Set-Cookie: auth_num=$code; expires=$date; path=/");
header("Set-Cookie: auth_num=$code;");
header("Cache-Control: no-cache");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
Header("Content-type: image/gif");
ImageGif($im);
ImageDestroy($im);

?>